#include <unordered_map>
class Solution {
public:
    int minNumberDisappeared(vector<int>& nums) {
        unordered_map<int, int> ht;
        sort(nums.begin(), nums.end());
        int res = -1;
        int n = nums.size();
        for (auto x: nums) {
            ht[x] = 1;
        }
        if (nums[0] <= 1) {
            for (int i = nums[0]; i <= nums[n-1]; ++i) {
                if (i > 0 && ht[i] != 1) {
                    res = i;
                    break;
                } 
            }
        } else {
            res = 1;
        }
        return res == -1 ? nums[n-1]+1 : res;
    }
};